/*
 * Classe SQL pour rechercher dans la base des rendez-vous
 */
function classSqlOrig(requeteSql){
	
	this.dbName = "storage.sdb";
	this.db = null;
	this.requeteSql = requeteSql;
	
	this.loadDB = function(){
		var file = Components.classes["@mozilla.org/file/directory_service;1"].getService(Components.interfaces.nsIProperties).get("ProfD", Components.interfaces.nsIFile);
	    file.append(this.dbName);//ligne12
	    var storage = Components.classes["@mozilla.org/storage/service;1"].getService(Components.interfaces.mozIStorageService);
	    var db = storage.openDatabase(file);
	    this.db = db;
	}
	
	this.getDB = function(){
		return this.db;
	}
	
	this.searchSqlOrig = function(db){
		var statement = Components.classes['@mozilla.org/storage/statement-wrapper;1'].createInstance(Components.interfaces.mozIStorageStatementWrapper);
		statement.initialize(this.db.createStatement(this.requeteSql));
		return statement;
	}
}


/*
 * Fonction d'exécution de SELECT
 * La requète est passée en paramètre de la fonction javascript dans le XUL
 */
function executeReqSqlOrig(requeteSql){
	//Autorisations
	netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
	//On instancie l'objet
	var sqlObj = new classSqlOrig(requeteSql);
	var statement = sqlObj.searchSqlOrig(sqlObj.loadDB());
	
	return statement;
}